//
//  verticalTwoTone.m
//  SKPAD
//
//  Created by admin@amonline.com.cn on 15/5/4.
//  Copyright (c) 2015年 amo. All rights reserved.
//

#import "VerticalTwoToneControl.h"

@implementation VerticalTwoToneControl

-(id) initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self)
    {
        self.backgroundColor = [UIColor clearColor];
        _minimumValue = 0.0;
        _maximumValue = 100.0;
        _value = 50.0;
        [self createVerticalTwoTone];
    }
    return self;
}


- (void)tintColorDidChange
{
    //_slip.color = [UIColor blackColor];
    //_trough.color = [UIColor yellowColor];
}

-(void) createVerticalTwoTone
{
    _trough = [[VerticalTwoToneTrough alloc] init];
    [_trough updateWithBounds:self.bounds];
    
    _slip = [[VerticalTwoToneSlip alloc] init];
    [_slip updateWithBounds:self.bounds];
    
    [self.layer insertSublayer:_slip.layerSlip atIndex:1];
    [self.layer insertSublayer:_trough.trackLayerblackTrough atIndex:0];
    [self.layer insertSublayer:_trough.trackLayerTrough atIndex:2];
}

-(void) setFirstColor:(UIColor *)firstColor
{
    if(firstColor != _firstColor)
    {
        _firstColor = firstColor;
        _slip.firstColor = firstColor;
    }
}

-(void) setSecondColor:(UIColor *)secondColor
{
    if(secondColor != _secondColor)
    {
        _secondColor = secondColor;
        _slip.secondColor = secondColor;
    }
}

//当前值
-(void) setValue:(CGFloat)value
{
    if(value != _value)
    {
        _value = value;
        _slip.value = (value - _minimumValue)/(_maximumValue - _minimumValue);
    }
}

-(void) setMinimumValue:(CGFloat)minimumValue
{
    if(minimumValue != _minimumValue)
    {
        _minimumValue = minimumValue;
    }
}

-(void) setMaximumValue:(CGFloat) maximumValue
{
    if(maximumValue != _maximumValue)
    {
        _maximumValue = maximumValue;
    }
}
//------

-(void) setLineWidth:(CGFloat)lineWidth
{
    if(lineWidth != _lineWidth)
    {
        _lineWidth = lineWidth;
        _slip.troughLineWidth = lineWidth;
        _trough.lineWidth = lineWidth;
    }
}	

//计量槽背景颜色
-(void) setBColor:(UIColor *)bColor
{
    if(bColor != _bColor)
    {
        _bColor = bColor;
        _trough.bColor = bColor;
    }
}

-(void) setLColor:(UIColor *)lColor
{
    if(lColor != _lColor)
    {
        _lColor = lColor;
        _trough.lColor = lColor;
    }
}
@end